from apps.common.base.dao import BaseDao
from apps.merchant.shop.serializers import *
from decimal import Decimal

class ShopDao(BaseDao):
    MODEL_CLASS = Shop
    SERI_CLASS = ShopBaseSerializer


    def create(self, data):
        try:
            if data.get('latitude'):
                data['latitude'] = str(Decimal(data.get('latitude')).quantize(Decimal('0.000000000')))
            if data.get('longitude'):
                data['longitude'] = str(Decimal(data.get('longitude')).quantize(Decimal('0.000000000')))
            # 调用父类的 create 方法
            shop_instance = super().create(data)
            return shop_instance
        except Exception as e:
            raise e